/*
 * Created on 06-dic-2004
 *
 */
package guru.merlin.server;


//import guru.merlin.core.CantHandException_;
import guru.merlin.core.CantHandException;
import guru.merlin.core.CantHandException;
import guru.merlin.core.Envelope;
import guru.merlin.core.EnvelopeHandler;
import guru.merlin.core.Route;
import guru.merlin.core.Router;

/**
 * @author cobach
 *
 */
public class PreRouter implements EnvelopeHandler{
    private String node;
    private Router router;
    
    public PreRouter(String n, Router r){
        node=n;
        router=r;
    }

    /* (non-Javadoc)
     * @see guru.merlin.core.EnvelopeHandler#handEnvelope(guru.merlin.core.Envelope)
     
    public void handEnvelope(Envelope envelope) throws CantHandException {
        envelope.setOriginRoute(new Route(node));
        router.handEnvelope(envelope);
    }*/
    
    /* (non-Javadoc)
     * @see guru.merlin.core.EnvelopeHandler#handEnvelope(guru.merlin.core.Envelope)
     */
    public Object handEnvelope(Envelope envelope) throws CantHandException {
        envelope.setOriginRoute(new Route(node));
        router.handEnvelope(envelope);        
        return envelope;
    }

    /* (sin Javadoc)
     * @see guru.merlin.core.EnvelopeHandler#retrieveEnvelope(java.lang.Object)
     */
    public void retrieveEnvelope(Object EnvelopeReference) throws CantHandException {
    }

    /* (sin Javadoc)
     * @see guru.merlin.core.EnvelopeHandler#commitHandEnvelope(java.lang.Object)
     */
    public void commitHandEnvelope(Object EnvelopeReference) throws CantHandException {
    }    
    
}
